<?php

session_start();
if (isset($_POST['login']) && isset($_POST['password'])) {
    $login = $_POST['login'];
    $password = $_POST['password'];
    $val = FALSE;

    $conexion = mysql_connect("localhost", "admin", "Xurpas123");
    mysql_select_db("smsnic", $conexion);

    $result1 = mysql_query("SELECT * FROM users where login = '" . $login . "'", $conexion) or die(mysql_error());

    if (mysql_num_rows($result1)) {
        while ($row1 = @mysql_fetch_array($result1)) {
            if ($password == $row1['psw']) {
                $val = TRUE;
                $_SESSION["nic_user"] = $row1['id'];
                ?>
                <script>
                    alert("Bienvenido!!!");	
                    location.href="A2P.php";
                </script>

                <?php

            }
        }
    }
    if ($val == FALSE) {
        ?>

        <script>
            alert("ERROR: Inicio de sesión inválido!");			
            location.href="./";
        </script>

        <?php

    }
}
?>